package xm.align
{
	import flash.display.DisplayObject;
	import xm.align.box.BaseAlignBox;
	import xm.align.box.info.AlignInfo;
	

	/**
	 * 설명         : 정렬 오브젝트 <br>
	 * 최초 작성  : 김정환 <br> 
	 * 수정         : <br>  
	 */
	public class AlignObject
	{
		
		//-----------------------------------------------------------------------------------
		// private vars
		//-----------------------------------------------------------------------------------
		private var _item : Object;
		private var _info : AlignInfo;
		private var _box : BaseAlignBox;
		
		//-----------------------------------------------------------------------------------
		// constructor
		//-----------------------------------------------------------------------------------
		/**
		 * @param __item : 정렬하고자 하는 children - DisplayObject 
		 * @param __info : 정렬 정보 - AlignInfo_VO
		 * @param __box : 정렬 정렬박스 - BaseAlign
		 */		
		public function AlignObject( __item:Object = null, __box:BaseAlignBox = null , __info:AlignInfo=null )
		{
			_item = __item;
			_box = __box;
			
			( __info == null ) ? _info = new AlignInfo() : _info = __info;
		}
		
		
		
		//-----------------------------------------------------------------------------------
		// public functions
		//-----------------------------------------------------------------------------------
		/**
		 * @param __padding 상 우 하 좌 ( 시계방향  )
		 * @return AlignObject
		 */		
		public function setAlignInfo( __padding:Array = null ):AlignObject
		{
			if( _info == null ) _info = new AlignInfo( __padding );
			else _info.padding = __padding;
			return this;
		}
		
		/**
		 * @param __item : 정렬 대상객체 < 단일 item : DisplayObject > 
		 * @return AlignObject
		 */		
		public function setItem( __item:Object ):AlignObject
		{
			_item = __item;
			return this;
		}
		
		/**
		 * @param __box : 정렬 대상객체 < BaseAlignBox를 상속받은 AlignHBox, AlignVBox >
		 * @return AlignObject
		 */		
		public function setBox( __box:BaseAlignBox ):AlignObject
		{
			_box = __box;
			return this;
		}
		
		
		
		
		
		//-----------------------------------------------------------------------------------
		// setter / getter
		//-----------------------------------------------------------------------------------
		
		/**
		 * @param __item 단일 setter, getter
		 */		
		public function set item( __item:Object ):void
		{
			_item = __item;
		}
		
		/**
		 * @param __info AlignInfo
		 */		
		public function set info( __info:AlignInfo ):void
		{
			_info = __info;
		}
		
		/**
		 * @param __box BaseAlignBox
		 */		
		public function set box( __box :BaseAlignBox ):void
		{
			_box = __box;
		}
		
		
		/**
		 * @return Object
		 */		
		public function get item():Object
		{
			return _item;
		}
		
		/**
		 * @return AlignInfo
		 */		
		public function get info():AlignInfo
		{
			return _info;
		}
		
		/**
		 * @return BaseAlignBox
		 */		
		public function get box():BaseAlignBox
		{
			return _box;
		}
		
		
		
		//-----------------------------------------------------------------------------------
		// destroy
		//-----------------------------------------------------------------------------------
		
		/**
		 * destory
		 */		
		public function destory():void
		{
			if( _item != null ) _item = null;
			if( _info != null )
			{
				_info.destroy(); 
				_info = null;
			}
			
			if( _box != null )
			{
				_box.destroy();
				_box = null;
			}
			
		}
	}
}